<template>
    <div id='' class='role_view'>
        <i-form ref="iFormRef" :config="formConfig"> </i-form>
        <div class="content">
            <div class="left">
                <div class="label">系统权限</div>
                <LeftTree ref="leftTreeRef" />
            </div>
            <div class="right">
                <div class="label">功能权限</div>
                <RightTree ref="rightTreeRef" />
            </div>
        </div>
    </div>
</template>
<script>
import { baseFormConfig } from './form_config'
import LeftTree from './left_tree.vue'
import RightTree from './right_tree.vue'
export default {
    name: '',
    props: [''],
    data() {
        this.baseConfig = icu.util.deepClone(baseFormConfig)
        return {
            formConfig: this.baseConfig,
            formData: {},
        };
    },
    components: { LeftTree, RightTree },
    computed: {},
    beforeMount() { },
    mounted() { },
    methods: {
        setData(data, treeData) {
            this.$refs.iFormRef.setData(data);
            this.setTreeList(treeData)
        },
        // 设置树数据
        setTreeList(treeData) {
            this.$refs.leftTreeRef.setTreeList(treeData.authen);
            this.$refs.rightTreeRef.setTreeList(treeData.function);
        },
        // 获取两棵树选中项
        getTreeCheck() {
            let arr1 = this.$refs.leftTreeRef.getCheckList();
            let arr2 = this.$refs.rightTreeRef.getCheckList();
            return [...arr1, ...arr2]
        },
        getForm(cb) {
            this.$refs.iFormRef.submit('userAddUpdata', (fromRes) => {
                this.formData = fromRes;
                if (cb) {
                    cb(this.formData)
                }
            })
        },
    },
    watch: {}
}
</script>
<style lang='less' scoped>
.role_view {
    height: 600px;
    overflow: auto;
    .content {
        display: flex;
        width: 100%;
        .left {
            width: 50%;
            display: flex;
        }
        .right {
            width: 50%;
            display: flex;
        }
        .label {
            padding: 8px 0 0 0;
            width: 25%;
            text-align: right;
            padding-right: 20px;
        }
    }
}
</style>